package cn.smbms.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.smbms.pojo.User;
import cn.smbms.tools.Constants;

import com.sun.istack.internal.logging.Logger;
/**
 * 拦截器
 * @author zhao'guang
 *
 */
public class SysInterceptor extends HandlerInterceptorAdapter {
	
	Logger logger = Logger.getLogger(SysInterceptor.class);
	
	public boolean preHandle(HttpServletRequest request,
							HttpServletResponse response,
							Object handler)throws Exception {
						logger.info("SysInterceptor==============");
		HttpSession session = request.getSession();
		User user = (User)session.getAttribute(Constants.USER_SESSION);
		if(user == null){
			response.sendRedirect(request.getContextPath()+"/401.jsp");
			return false;
		}
		return true;					
	}
}
